﻿@{
    Layout = null;
}
@model webui.ViewModel.V_NewsComment

<!DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>@ViewBag.news.title</title>
    <link href="../../Content/layout.css" rel="stylesheet" />
    <link href="~/Content/NavPager.css" rel="stylesheet" />
    @Scripts.Render("~/mvcAjax")

    <style>
        #jingcai-com-title {
            font-size: 16px;
            border-bottom: 2px solid #75cc75;
            padding: 6px 0;
        }

        #jingcai-com li {
            padding: 25px 0 11px;
            border-bottom: 1px dotted #d9d9d9;
            zoom: 1;
        }

        #jingcai-com .com-avatar-right {
            margin-left: 65px;
            zoom: 1;
        }

        #jingcai-com .com-avatar img {
            float: left;
            width: 42px;
            height: 42px;
        }

        #jingcai-com .com-top {
            color: #31a831;
            margin-bottom: 6px;
            font-size: 12px;
        }

        #jingcai-com .com-ext {
            float: right;
            color: #d9d9d9;
        }

        #jingcai-com .com-txt {
            font-size: 14px;
            padding: 4px 0;
        }


        #jingcai-com .show_floor {
            background: #eee;
            color: #666;
            height: 25px;
            line-height: 25px;
            display: block;
            text-align: center;
        }
    </style>
    <script type="text/javascript">
        $(document).ready(function () {

            $("#newsid").val("@ViewBag.news.id");  //设置给提交评论用
            AddValidateCode();
            initTable();

        })


        //初始化表格
        function initTable(postData) {
            if (postData == null || postData == "") {
                postData = "id=" + GetQueryString("id");
            }
            $.getJSON("GetPageComment", postData, function (jsondate) {
                $("#newslist").html("");
                var strTr = ""
                for (var i in jsondate.Data.NewsList) {
                    var time = eval('new ' + (jsondate.Data.NewsList[i].addtime.replace(/\//g, '')));

                    strTr += "<li class=\"hidden_more\"> <div class=\"com-avatar\"><img src=\"../../images/usercomment.jpg\"></div>";
                    strTr += "  <div class=\"com-avatar-right\">  <div class=\"com-top\"> <span class=\"com-ext\">  " + time.format("yyyy年MM月dd日hh:mm") + " </span>  <span>" + jsondate.Data.NewsList[i].nickName + "</span> </div><p class=\"com-txt\"> " + jsondate.Data.NewsList[i].Comment + "</p> </div>    </li>";

                }
                $("#newslist").append(strTr);
                //把分页的标签放到页面里面去
                $("#navDiv").html(jsondate.Data.NavHtml);

                //给分页的超级链接绑定点击事件
                $(".pageLink").click(function () {
                    var href = $(this).attr("href");
                    var queryString = "id=" + GetQueryString("id") + "&";
                    queryString = queryString + href.substr(href.lastIndexOf('?') + 1);
                    initTable(queryString);
                    return false;
                });
            });
        }


        //获取地址栏的参数
        function GetQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;
        }

        //json 时间转换方法
        Date.prototype.format = function (format) {
            /*
             * format="yyyy-MM-dd hh:mm:ss";
             */
            var o = {
                "M+": this.getMonth() + 1,
                "d+": this.getDate(),
                "h+": this.getHours(),
                "m+": this.getMinutes(),
                "s+": this.getSeconds(),
                "q+": Math.floor((this.getMonth() + 3) / 3),
                "S": this.getMilliseconds()
            };
            if (/(y+)/.test(format)) {
                format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            }
            for (var k in o) {
                if (new RegExp("(" + k + ")").test(format)) {
                    format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
                }
            }
            return format;

        };


        //添加评论
        function AddSuccess(jsonData) {

            if (jsonData.Status=="ok") {
                alert("添加成功");
                initTable();

                $("#Comment").val("");
                $("#verfiy").val("");
                var num = $("#imgCode").attr("src");
                $("#imgCode").attr("src", num + 1);
                alert("ssxx");
            }
            else {
                alert(jsonData.Msg);
            }
        }

        //刷新验证码
        function AddValidateCode() {
            $("#imgCode").click(function () {
                var num = $("#imgCode").attr("src");
                $("#imgCode").attr("src", num + 1);
            })
        }

    </script>



</head>

<body>
    <div id="container">
        <div id="header">
            <div id="logo"><img src="../../images/logo.gif" alt="企业名称" width="181" height="45" /></div>
            <div id="search">
                <form id="form1" name="form1" method="post" action="">
                    搜索产品
                    <input class="inp_srh" type="text" name="textfield" id="textfield" />
                    <input class="btn_srh" type="submit" name="button" id="button" value="查询" />
                </form>
            </div>
        </div>
        <div class="clearfloat"></div>
        <div id="nav">
            <div id="nav_l"></div>
            <div id="nav_r"></div>
            <div class="nav_main">
                <ul>
                    <li><a href="~/home/index"><span>首页</span></a></li>
                    @foreach (var item in (List<Models.NewsType>)ViewBag.newstype)
                    {
                        <li><a href="ntype?typeid=@item.id"><span>@item.typeName </span></a></li>
                    }

                </ul>
            </div>

        </div>
        <div class="clearfloat"></div>
        <div id="maincontent">
            <div id="main">
                <div class="box_plist">
                    <h2><span>新闻详情</span></h2>
                    <div class="box_list">

                        <div style="text-align:center">

                            <h1> @ViewBag.news.title </h1>
                        </div>

                        <table width="97%" align="center">
                            <tr>
                                <td align="center">
                                    [日期：@ViewBag.news.addtime.ToString("yyyy-MM-dd") ]  &nbsp;&nbsp;|&nbsp;&nbsp;
                                    [  来源：@ViewBag.news.newsSource]     &nbsp;&nbsp;|&nbsp;&nbsp;
                                    [ 类型：@ViewBag.typename]
                                </td>
                            </tr>
                        </table>
                        <div id="content">

                            @if (!string.IsNullOrEmpty(@ViewBag.news.newsImage))
                            {
                                @Html.Raw("   <img id='result'  src='../../upimg/" + @ViewBag.news.newsImage + "'/>")
                            }
                            <p></p>
                            @Html.Raw(@ViewBag.news.content)

                        </div>
                    </div>
                    <br /><br /><br /><br />



                    <div id="jingcai-com">
                        <div id="jingcai-com-title">精彩评论</div>

                        @using (Ajax.BeginForm(new AjaxOptions()
                        {
                            HttpMethod = "post",
                            OnSuccess = "AddSuccess",
                            Url = "Addcomment"
                        }))
                        {
                            @Html.HiddenFor(p => p.newsid);

                            <table width="97%" align="center" style="margin-top:20px;">
                                <tr>
                                    <td> 昵称</td>
                                    <td>

                                        @Html.TextBoxFor(p => p.nickName, new { style = "width:100px;" })
                                        @Html.ValidationMessageFor(p => p.nickName)

                                    </td>
                                </tr>
                                <tr>
                                    <td> 内容</td>
                                    <td>
                                        @Html.TextAreaFor(p => p.Comment, new { style = "width:400px;", rows = "3" })
                                        @Html.ValidationMessageFor(p => p.Comment)
                                    </td>
                                </tr>
                                <tr>
                                    <td> 验证码</td>
                                    <td>
                                        <img src="/home/GetValidateCode?ID=1" id="imgCode" alt="验证码" />
                                        @Html.TextBoxFor(p => p.verfiy, new { style = "width:70px;" })
                                        @Html.ValidationMessageFor(p => p.verfiy)
                                        <input id="btnAddComent" type="submit" value="发表评论" />
                                    </td>

                                </tr>
                            </table>
                        }
                        <div style="background-color:#808080; width:620px;height:1px;"> </div>

                        <ul class="jingcai-list" id="newslist">



                            <li class="hidden_more">
                                <div class="com-avatar"><img src="http://www.xiazaiba.com/static/images/default_avatar.gif"></div>
                                <div class="com-avatar-right">
                                    <div class="com-top">
                                        <span class="com-ext"> 2011年04月20日 07:16</span>
                                        <span>我下载了</span>
                                    </div>
                                    <p class="com-txt">置顶的帖子说的没错，可以汉化，谢谢！</p>
                                </div>
                            </li>


                        </ul>

                        <div class="paginator" id="navDiv">  </div>
                    </div>
                </div>


            </div>

            <div id="side">

                <div class="side_box">
                    <h2><strong> 阅读</strong>排行</h2>
                    <div class="side_con ask">
                        @foreach (var item in (List<Models.NewsContent>)ViewBag.newsHot)
                        {
                            <dl>
                                <dt><a href="newsdetail?id=@item.id">@item.title</a></dt>
                            </dl>
                        }


                    </div>
                </div>
                <div class="side_box">
                    <h2><strong>联系</strong>我们</h2>
                    <div class="side_con contact"><img src="../../images/tel.gif" alt="联系我们" width="222" height="112" /></div>
                </div>
            </div>
        </div>
        <div class="clearfloat"></div>
        <div id="footer">
            <dl>
                <dt><a href="#">关于我们</a>　||　<a href="#">产品目录</a>　||　<a href="#">联系我们</a>　||　<a href="#">友情链接</a>　||　<a href="#">反馈问题</a>　||　<a href="#">广告合作</a></dt>
                <dd>
                    Copyright &copy; 2007 - 2010 aa25.cn   All Rights Reserved<br />
                    标准之路  版权所有  京ICP备10007159号
                </dd>
            </dl>
        </div>
    </div>
</body>
</html>
